#ifndef __CE_SCENE_SECTOR_H__
#define __CE_SCENE_SECTOR_H__

#include <export.h>
#include <iobject.h>
#include <scene/node.h>
#include <list>
#include <set>
#include <vector>

class cePortal;

/**
 * \addtogroup scene
 * @{
 */
/**
 * @brief The sector building spatially nodes grouped together.
 */
class CE_API ceSector : public iObject
{
  friend class Scene;
  CE_OBJECT
private:
  NodeList								_nodes;

	std::set<ceLight*>			_lights;

	std::vector<cePortal*>	_portals;

	unsigned								_lastScannedFrame;
public:
  ceSector();

  void AddNode (ceNode* node);
  void RemoveNode (ceNode* node);
  NodeList& GetNodes ();

	void AddLight (ceLight* light);
	void AddLightNode (ceNode* node);

	void FindSectorLights (bool clearLights);
	void ApplyLights ();

  cePortal* Connect (ceSector* other);
  cePortal* GetPortal (ceSector* other);
  const cePortal* GetPortal (const ceSector* other) const;

	unsigned GetNumberOfPortals () const;
	cePortal* GetPortal (unsigned idx);
	const cePortal* GetPortal (unsigned idx) const;

	void SetLastScannedFrame (unsigned frame);
	unsigned GetLastScannedFrame () const;
};

typedef ceSector* ceSectorPtr;
typedef std::list<ceSectorPtr> ceSectorList;
typedef std::list<ceSectorPtr>::iterator ceSectorListIterator;

/** @} */

#endif /* ! __CE_SCENE_SECTOR_H__ */
